<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>jQuery留言板</title>
		<script src="jquery-3.6.0.js"></script>
		<style type="text/css">
			#bt1,#bt2{
				position: relative;
				left: 60px;    
			}
		</style>
	</head>
	<body>
		<form action="" method="">       
			姓名:<input type="text" id="name"/><br>
			留言:
			<textarea id="text1" rows="3px" cols="25px"></textarea><br>
			<input type="reset" id="bt1" value="重置" />
			<input type="button"  id="bt2" value="留言" /><br>
			<textarea id="text2" rows="10px" cols="45px" disabled="disabled">	   
			</textarea>
			<script src="js/jquery-3.6.0.js"></script>    
			<script type="text/javascript">
				var time = new Date;
				var arr=[];
				$("#bt2").click(function(){
					var texts = '['+$("#name").val()+']'+'在'+time.toLocaleTimeString()+'说'+$("#text1").val()+'\n';
					arr.unshift(texts);
					$("#text2").html('');
					if(arr.length>10){
						arr.splice(10);
					}
						$("#text2").html($("#text2").html()+arr.join('') );
					}
					)
			</script>
		</form>
	</body>
</html>